/**
 * Copyright (c) 2013, RMIT University, Australia.
 * All rights reserved.
 * 
 * This code is under the BSD license. See 'license.txt' for details.
 * Project hosted at: https://code.google.com/p/climate-smart-seaports/
 */
package war.model;

import java.util.Date;

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.OneToOne;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

/**
 * Class representing a seaport's vulnerability Data Element
 * @author Guillaume Prevost
 * @since 26th Mar. 2013
 */
@Entity
@DiscriminatorValue(value = "Vulnerability")
public class DataElementVulnerability extends DataElement {

	private static final long serialVersionUID = -1308795024262635690L;
	
	/**
	 * The weather event related to this vulnerability
	 */
    @OneToOne
    @Cascade(value = CascadeType.DELETE)
	private WeatherEvent weatherEvent;
        
	/**
	 * Default constructor of DataElementVulnerability
	 */
	public DataElementVulnerability() {
		super();
	}
	
	/**
	 * Constructor of DataElementVulnerability specifying all the fields
	 * @param creationDate: the date when the data element was created
	 * @param name: the name of the data element
	 * @param position: the position of the data element in the user story it belongs to
	 * @param displayType: the way the data element should be displayed
	 * @param userStory: the user story to which this data element belongs
	 * @param weatherEvent: the weather event related to this vulnerability
	 */
	public DataElementVulnerability(Date creationDate, String name, boolean included, int position, DisplayType displayType, UserStory userStory, WeatherEvent weatherEvent) {
		super(creationDate, name, included, position, displayType, userStory);
		this.weatherEvent = weatherEvent;
	}
	
	/**
	 * Getter for the weather event related to this vulnerability
	 * @return The current weather event related to this vulnerability
	 */
	public WeatherEvent getWeatherEvent() {
		return this.weatherEvent;
	}
	
	/**
	 * Setter for the weather event related to this vulnerability
	 * @param csiroDataList: the new weather event related to this vulnerability
	 */
	public void setWeatherEvent(WeatherEvent weatherEvent) {
		this.weatherEvent = weatherEvent;
	}
	
	public static long getSerialversionuid() {
		return serialVersionUID;
	}
}